package com.aigc.sclassroom.mapper;

import com.aigc.sclassroom.pojo.Content;
import com.aigc.sclassroom.pojo.Plan;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PlanMapper {

    @Insert("insert into plan(plan_name,create_time)\n" +
            "values (#{planName},now()) ")
    @Options(useGeneratedKeys = true, keyProperty = "planId", keyColumn = "plan_id")
    void add(Plan plan);

    @Insert("insert into plan_content(content, plan_id, create_time)\n" +
            "values (#{content},#{planId},now())")
    void addContents(String content,Long planId);

    @Select("select plan_id,plan_name\n" +
            "from plan\n" +
            "where class_id=#{classId}")
    List<Plan> selectPlanByClassId(Long classId);

    @Select("select content\n" +
            "from plan_content\n" +
            "where plan_id =#{planId}")
    String[] selectPlanContentByPlanId(Long planId);

    @Update("update plan\n" +
            "set class_id=#{classId}\n" +
            "where plan_id = #{plan_id}")
    Long updatePlan(Long classId,Long plan_id);

    @Select("select * from plan where plan_id=#{planId}")
    Plan getPlanById(Long planId);
}
